/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tableview;

import data.Desiglayer;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Hùng
 */
public class DesignLayerTableView extends AbstractTableModel {

    List<Desiglayer> lDLayer;

    public DesignLayerTableView() {
        this(new ArrayList<Desiglayer>());
    }

    public DesignLayerTableView(List<Desiglayer> lDLayer) {
        this.lDLayer = lDLayer;
    }

    public List<Desiglayer> getlDLayer() {
        return lDLayer;
    }

    public void setlDLayer(List<Desiglayer> lDLayer) {
        this.lDLayer = lDLayer;
    }

    @Override
    public int getRowCount() {
        if (lDLayer != null) {
            return lDLayer.size();
        }
        return 0;
    }

    @Override
    public int getColumnCount() {
        return 3;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Object value = null;
        Desiglayer tmpLayer = this.lDLayer.get(rowIndex);
        switch (columnIndex) {
            case 0:
                value = tmpLayer.getDesignation().getDesignation();
                break;
            case 1:
                value = tmpLayer.getLayer();
                break;
            case 2:
                value = tmpLayer.getWeightage();
                break;

        }
        return value;
    }

    @Override
    public String getColumnName(int column) {
        String value = "";
        switch (column) {
            case 0:
                value = "DesignId";
                break;
            case 1:
                value = "Layer";
                break;
            case 2:
                value = "Weightage";
                break;
        }
        return value;
    }
}
